//
//  GateViewController.m
//  Tank For IPhone
//
//  Created by 奕 朱 on 11-2-25.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "GateViewController.h"
#import "Constant.h"
#import "Integer.h"


@implementation GateViewController
@synthesize gateView;
@synthesize upButton;
@synthesize downButton;
@synthesize leftButton;
@synthesize rightButton;
@synthesize fireButton;

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {

	self.gateView = nil;
	self.upButton = nil;
	self.downButton = nil;
	self.leftButton = nil;
	self.rightButton = nil;
	self.fireButton = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	
	[gateView release];
	[upButton release];
	[downButton release];
	[leftButton release];
	[rightButton release];
	[fireButton release];
    [super dealloc];
	
}

- (IBAction) buttonPressed: (id) sender {
		
	if (sender == upButton) {
		[gateView.tank move: [[Integer alloc] init: up]];
	} else if (sender == downButton) {
		[gateView.tank move: [[Integer alloc] init: down]];
	} else if (sender == leftButton) {
		[gateView.tank move: [[Integer alloc] init: left]];
	} else if (sender == rightButton) {
		[gateView.tank move: [[Integer alloc] init: right]];
	} else if (sender == fireButton) {
		[gateView.tank fire];
	}
	
}


@end
